<!DOCTYPE html>
<html>
    <body>
<?php
    include('sql.php');
    $number = trim($_POST['number']);
    $password = trim(md5($_POST['password']));
    $name = trim($_POST['name']);
    $telephone = trim($_POST['telephone']);
    $mail = trim($_POST['mail']);
    $ip = $_SERVER["REMOTE_ADDR"];
    $time = time();
    if (empty($number)) { ?>
    <div class="reg_box_result">
        <div class="reg_success">
            <p style="margin-bottom: 18px;">证件号不能为空！</p>
        </div>
    </div>
    <?php } else { if (empty($password)) { ?>
    <div class="reg_box_result">
        <div class="reg_success">
            <p style="margin-bottom: 18px;">密码不能为空！</p>
        </div>
    </div>
    <?php } else { if (empty($name)) { ?>
    <div class="reg_box_result">
        <div class="reg_success">
            <p style="margin-bottom: 18px;">姓名不能为空！</p>
        </div>
    </div>
    <?php } else { if (empty($telephone)) { ?>
    <div class="reg_box_result">
        <div class="reg_success">
            <p style="margin-bottom: 18px;">手机号码不能为空！</p>
        </div>
    </div>
    <?php } else { if (empty($mail)) { ?>
    <div class="reg_box_result">
        <div class="reg_success">
            <p style="margin-bottom: 18px;">邮箱不能为空！</p>
        </div>
    </div>
    <?php } else {
        $query = "SELECT * FROM user WHERE number = '$number'";
        $num_result = mysqli_query($link, $query);
        if (mysqli_num_rows($num_result) > 0) { ?>
    <div class="reg_box_result">
        <div class="reg_success">
            <p style="margin-bottom: 18px;">证件号码已存在！请直接用于登入！</p>
        </div>
    </div>
    <?php } else {
        $reg_sql = "insert into user (id,number,password,name,telephone,mail,ip,time,exnumber,photo,address) values ('','$number','$password','$name','$telephone','$mail','$ip','$time','$time','','')";
        $reg_row = $link->query($reg_sql);
        if ($reg_row) { ?>
    <div class="reg_box_result">
        <div class="reg_success">
            <p style="margin-bottom: 18px;">恭喜您，注册成功！</p>
            <a href="/" class="reg">开始报名</a>
        </div>
    </div>
    <?php } else { ?>
    <div class="reg_box_result">
        <div class="reg_success">
            <p style="margin-bottom: 18px;">很遗憾，注册失败，请联系网站管理员。</p>
        </div>
    </div>
    <?php } } } } } } } ?>
    </body>
</html>